n = 2000
log = list([0] * 3 for _ in range(n))
for i in range(n):
    log[i][0], log[i][1], log[i][2] = input().split()
combo = 1
ans = []

for i in range(1, n):
    if log[i][0] == log[i][1] and int(log[i][2]) - int(log[i-1][2]) <= 1000:
        combo += 1
    else:
        ans.append(combo)
        combo = 1

print(max(ans))